<template>
  <div class="home_wrapper">
    <div class="system_info">
      <div class="system_name">智慧农业全生命周期监测云平台</div>
      <div class="weather">
        <ul>
          <li class="date">
            12:22:12.352<br />
            <span>2019.7.10</span>
          </li>
          <li class="degree">
            <img src="@/images/home/tianqi.png" alt="" />
            <span>26℃</span>
          </li>
          <li class="pm_co">
            PM2.0<br />
            <span>31</span>
          </li>
          <li class="pm_co">
            PM1.0<br />
            <span>31</span>
          </li>
          <li class="pm_co">
            CO2<br />
            <span>31</span>
          </li>
        </ul>
      </div>
    </div>
    <div class="system_detail">
      <!-- <div class="home_map">
        <img src="@/images/home/homeMap.png" alt="" />
      </div> -->

      <!-- 左侧介绍 -->
      <div class="left">
        <div class="left_top">
          <div class="top1">
            <img src="@/images/home/logo1.png" alt="" />
          </div>
          <div class="top2">
            <img src="@/images/home/china.png" alt="" />
            <div>地块状态</div>
          </div>
        </div>
        <div class="left_bottom">
          <div class="bottom1">
            <div>农作物用地</div>
          </div>
          <div class="bottom2">
            本项目地块位于昆仑路，周边植被茂密，生态环境优良,具有得天独厚的山水资源基础和优势。且有村道可直达村内和208省道。
          </div>
          <div class="bottom3">
            <div class="bottom3_child">
              <div class="bottom3_child_child" v-for="(item, i) in state.landInfo" :key="i">
                <div class="names">{{ item.name }}</div>
                <div class="values">{{ item.value }}</div>
              </div>
            </div>
          </div>
          <div class="bottom4">
            <img src="@/images/home/home_pic1.png" alt="" />
          </div>
          <div class="bottom5">备注:以上地块技术指标以正式公告为准</div>
        </div>
      </div>

      <!-- 中间地图 -->
      <div class="middle">
        <div class="mid_title">吉林省农作信息状态</div>
        <div class="mid_map"></div>
        <div class="dialog">
          <div class="inner_div">
            <i class="close"></i>
            <div class="location">长春市</div>
            <div class="l_item">
              <div>地块总数</div>
              <div><span style="color: #00ffba">2</span>个</div>
            </div>
            <div class="l_item">
              <div>农作物种类</div>
              <div><span style="color: #f9d24c">3</span>个</div>
            </div>
          </div>
        </div>
        <div class="mid_pics">
          <div class="pic_div" v-for="(item, i) in state.midPics" :key="i">
            <div class="pics" @click="toPage(item.url)">
              <img :src="item.pic" alt="" />
            </div>
            <div class="tips" @click="toPage(item.url)">{{ item.tips }}</div>
          </div>
        </div>
      </div>

      <!-- 右侧图表 -->
      <div class="right">
        <div class="r_top">
          <div class="right_title">天气状态</div>
          <div class="weather_list">
            <div class="items" v-for="(item, i) in state.weatherList" :key="i">
              <div><img :src="item.icon" alt="" /></div>
              <div>{{ item.tips }}</div>
              <div>{{ item.value }}</div>
            </div>
          </div>
        </div>
        <div class="r_middle">
          <div class="right_title">农作物统计</div>
          <div class="echarts_box">
            <echarts-box :option="state.statistics"></echarts-box>
          </div>
        </div>
        <div class="r_bottom">
          <div class="right_title">农作物统计</div>
          <div class="echarts_box">
            <echarts-box :option="state.leida"></echarts-box>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import echartsBox from "@/components/echarts-box.vue";
import { onMounted, reactive } from 'vue-demi';
import { useRouter } from 'vue-router';
import mid1 from '@/images/home/1.png'
import mid2 from '@/images/home/2.png'
import mid3 from '@/images/home/3.png'
import mid4 from '@/images/home/4.png'
import mid5 from '@/images/home/5.png'
import weather1 from '@/images/home/sswendu.png'
import weather2 from '@/images/home/fengsu.png'
import weather3 from '@/images/home/shidu.png'
import weather4 from '@/images/home/jiangshui.png'
import weather5 from '@/images/home/fengxiang.png'
const state = reactive({
  landInfo: [
    { name: "地块名称", value: "储出[2020]42号" },
    { name: "区域", value: "长春市区" },
    { name: "面积", value: "0.966亩" },
    { name: "容积率", value: "≥1.3，≤1.5" },
    { name: "用地类型", value: "农业用地" },
    { name: "面积", value: "0.966亩" },
    { name: "容积率", value: "≥1.3，≤1.5" },
    { name: "用地类型", value: "农业用地" },
  ],
  midPics: [
    {
      pic: mid1,
      tips: "土壤墒情监测平台",
      url: "/soil",
    },
    {
      pic: mid2,
      tips: "玉米长势监测平台",
      url: "/corn",
    },
    {
      pic: mid3,
      tips: "智慧大棚监测",
      url: "/greenhouse",
    },
    {
      pic: mid4,
      tips: "耕地监测子系统",
      url: "/cultivated",
    },
    {
      pic: mid5,
      tips: "农业物联网平台",
      url: "/ai",
    },
  ],
  weatherList: [
    {
      icon: weather1,
      tips: "实时温度",
      value: "25℃",
    },
    {
      icon: weather2,
      tips: "风速",
      value: "10m/s",
    },
    {
      icon: weather3,
      tips: "当前湿度",
      value: "57℃",
    },
    {
      icon: weather4,
      tips: "近1小时降水",
      value: "0",
    },
    {
      icon: weather5,
      tips: "风向",
      value: "东南",
    },
  ],
  statistics: {
    backgroundColor: "rgba(0,0,0,0)",
    grid: { top: "20%", left: "10%", right: "10%", bottom: "15%" },
    tooltip: {
      trigger: "axis",
      formatter: "{b0}({a0}): {c0}<br />{b1}({a1}): {c1}%",
    },
    legend: {
      data: ["NDVI", "NDWI"],
    },
    xAxis: {
      axisTick: {
        //x轴刻度线
        show: false,
      },
      axisLabel: { show: false }, //显示x轴的数值

      data: [
        "玉米",
        "水稻",
        "小麦",
        "玉米1",
        "水稻1",
        "小麦1",
        "玉米2",
        "水稻2",
      ],
    },
    yAxis: [
      {
        type: "value",
        // name: "数据1",
        show: true,
        scale: true,
        max: 100,
        min: 0,
        splitNumber: 5,
        boundaryGap: [0.2, 0.2],
        // axisLabel: { show: false }, //显示x轴的数值

        axisLine: {
          lineStyle: {
            color: "#5e859e",
            width: 2,
          },
        },
      },
      {
        type: "value",
        // name: "数据2",
        min: 0,
        max: 100,
        interval: 10,
        axisLabel: { show: false }, //显示x轴的数值

        axisLine: {
          lineStyle: {
            color: "#5e859e", //纵坐标轴和字体颜色
            width: 2,
          },
        },
      },
    ],
    series: [
      {
        name: "NDVI",
        type: "bar",
        barWidth: 15,
        itemStyle: {
          barBorderRadius: [6, 6, 0, 0],
        },
        data: [15, 20, 35, 40, 50, 60, 99, 88],
      },
      {
        name: "NDWI",
        type: "line",
        smooth: true,
        symbolSize: 8, //设定实心点的大小
        itemStyle: {
          normal: {
            color: "#fff", //改变折线点的颜色
            lineStyle: {
              color: "#E85D61", //改变折线颜色
              width: 5, // 0.1的线条是非常细的了
            },
          },
        },
        data: [15, 30, 21, 20, 20, 30, 50, 90],
      },
    ],
  },

  // 雷达图
  leida: {
    backgroundColor: "rgba(0,0,0,0)",
    tooltip: {},
    radar: {
      name: {
        textStyle: {
          color: "#fff",
        },
      },
      indicator: [],
    },
    series: [],
  },
  source: {
    data: [122, 144, 313, 414, 119, 216, 219, 241, 151, 116, 117],
    indicator: [
      { name: "农安县", max: 222 },
      { name: "双阳区", max: 442 },
      { name: "南关区", max: 332 },
      { name: "宽城区", max: 442 },
      { name: "朝阳区", max: 992 },
      { name: "二道区", max: 312 },
      { name: "绿园区", max: 222 },
      { name: "双阳区", max: 332 },
      { name: "九台区", max: 323 },
      { name: "榆树市", max: 222 },
      { name: "德惠市", max: 222 },
    ],
  }
})

onMounted(() => {
  state.leida.series = buildSeries(state.source.data)
  state.leida.radar.indicator = state.source.indicator
})
const router = useRouter()
const toPage = (url) => {
  router.push(url)
}
const buildSeries = (data) => {
  const helper = data.map((item, index) => {
    const arr = new Array(data.length);
    arr.splice(index, 1, item);
    return arr;
  });

  return [data, ...helper].map((item, index) => {
    return {
      type: "radar",
      symbol: index === 0 ? "circle" : "none",
      symbolSize: 6,
      itemStyle: {
        color: "#fff",
      },
      areaStyle: {
        color: index === 0 ? "#2b92b8" : "transparent",
        opacity: 0.5,
      },
      tooltip: {
        show: index === 0 ? false : true,
        formatter: function () {
          return (
            state.source.indicator[index - 1].name + "：" + state.source.data[index - 1]
          );
        },
      },
      z: index === 0 ? 1 : 2,
      data: [item],
    };
  });
};
</script>

<style lang="scss" scoped>
.home_wrapper {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: url("@/images/home/homeMap.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  color: #fff;
  font-weight: 600;
  .system_info {
    width: 100%;
    height: 120px;
    position: relative;

    .system_name {
      width: 100%;
      text-align: center;
      font-size: 32px;
      padding-top: 45px;
      font-weight: bolder;
    }

    .weather {
      position: absolute;
      top: 22px;
      right: 10px;

      ul>li {
        display: inline-block;
        text-align: right;
        border-right: 1px solid #8c8c8a;
        padding: 0 25px;
      }

      .date {
        font-size: 20px;
        font-weight: bolder;

        span {
          font-size: 10px;
          color: #969696;
        }
      }

      .degree {
        display: inline-block;

        img {
          width: 48px;
          height: 37px;
          vertical-align: bottom;
        }

        span {
          display: inline-block;
          font-size: 23px;
          font-weight: bolder;
        }
      }

      .pm_co {
        font-size: 12px;
        line-height: 24px;
        color: #8c8d90;

        span {
          font-size: 14px;
          color: #ffffff;
          font-weight: bolder;
        }
      }
    }
  }

  .system_detail {
    padding: 0 100px 50px 100px;
    display: flex;
    // width: 100%;
    height: calc(100vh - 120px);
    position: relative;

    .home_map {
      // z-index: -1;
      position: absolute;
      // width: 100%;
      // height: 100%;
      top: 0;
      left: 0;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .left {
      width: 329px;
      height: 100%;
      display: flex;
      flex-direction: column;

      .left_top {
        display: flex;
        height: 68px;
        margin-bottom: 20px;

        .top1 {
          width: 68px;
          margin-right: 15px;
          img{
            width:100%;
            object-fit: contain;
          }
        }

        .top2 {
          flex: 1;
          background: url("@/images/home/divBg2.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;

          img {
            // margin: 10px 0 0px 10px;
            width: 100%;
            object-fit: contain;
          }

          div {
            font-size: 22px;
            font-weight: bolder;
            padding-left: 40px;
            background-image: linear-gradient(#e2f0fe, #2b92b8);
            -webkit-background-clip: text;
            color: transparent;
            margin-top: -5px;
          }
        }
      }

      .left_bottom {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        background: url("@/images/home/divBg1.png");
        background-repeat: no-repeat;
        background-size: 100% 100%;

        .bottom1 {
          font-size: 20px;
          font-weight: bolder;
          padding: 22px;
          flex: 1;
          position: relative;

          div {
            position: absolute;
            left: 0;
            width: 251px;
            height: 45px;
            line-height: 45px;
            padding-left: 22px;
            background: url("@/images/home/txtBg.png");
            background-repeat: no-repeat;
            background-size: 100% 100%;
          }
        }

        .bottom2,
        .bottom3,
        .bottom4,
        .bottom5 {
          padding: 0 22px;
        }

        .bottom2 {
          flex: 2;
          font-size: 12px;
          line-height: 30px;
        }

        .bottom3 {
          margin: 20px 0;
          flex: 6;
          display: flex;
          flex-direction: column;
          justify-content: space-around;

          .bottom3_child {
            width: 100%;
            height: 100%;
            border: 1px solid #005696;
            display: flex;
            flex-direction: column;

            >div {
              flex: 1;
            }

            >div:nth-of-type(2n-1) {
              background: #0a436d;
            }

            .bottom3_child_child {
              height: 100%;
              display: flex;
              justify-content: center;
              align-items: center;

              .names {
                flex: 1;
                height: 100%;
                text-align: right;
                font-size: 14px;
                font-weight: bolder;
                padding-right: 10px;
                border-right: 1px solid #005696;
              }

              .names::before {
                display: inline-block;
                content: "";
                height: 100%;
                vertical-align: middle;
              }

              .values {
                flex: 2;
                text-align: left;
                font-size: 12px;
                color: #98d2f3;
                padding-left: 10px;
              }
            }
          }
        }

        .bottom4 {
          flex: 3;
          height: 222px;

          img {
            width: 100%;
            object-fit: cover;
          }
        }

        .bottom5 {
          // height: 44px;
          flex:1;
          margin-top: 10px;;
          font-size: 12px;
          color: #98d2f3;
          text-align: center;
          // line-height: 44px;
        }
      }
    }

    .right {
      width: 386px;
      height: 100%;
      display: flex;
      flex-direction: column;

      >div {
        margin-bottom: 20px;
      }

      :nth-of-type(3) {
        margin-bottom: 0;
      }

      .r_top {
        flex: 7;
        background: url("@/images/home/tqBg.png") no-repeat;
        background-size: 100% 100%;
      }

      .r_middle {
        flex: 8;
      }

      .r_bottom {
        flex: 9;
      }

      .r_middle,
      .r_bottom {
        background: url("@/images/home/titBg.png") no-repeat;
        background-size: 100% 100%;
      }

      .r_top,
      .r_middle,
      .r_bottom {
        .right_title {
          width: 100%;
          font-size: 20px;
          font-weight: bolder;
          padding: 10px 25px 20px 25px;
        }

        .weather_list {
          width: 100%;
          display: inline-block;

          >div {
            width: calc(100% / 2);
          }

          .items {
            display: inline-block;
            margin-block: 10px;

            div {
              display: inline-block;
              margin-right: 10px;
              font-size: 14px;
              font-weight: bolder;

              img {
                margin: 0 0px 0 30px;
                width: 20px;
                height: 20px;
                vertical-align: middle;
              }
            }

            &:nth-last-of-type() {
              text-align: right;
            }
          }
        }

        .echarts_box {
          width: 100%;
          height: calc(100% - 45px);
        }
      }
    }

    .middle {
      flex: 1;
      margin: 0 25px;
      display: flex;
      flex-direction: column;
      position: relative;

      .dialog {
        width: 267px;
        height: 172px;
        background: url("@/images/home/txtBg1.png") no-repeat;
        background-size: 100% 100%;
        position: absolute;
        top: 250px;
        left: 90px;

        .inner_div {
          // width: 100%;
          // height: 100%;
          position: relative;
          padding: 0 40px 0 30px;

          .close {
            display: block;
            width: 16px;
            height: 16px;
            background: url("@/images/home/close.png") no-repeat;
            background-size: 100% 100%;
            cursor: pointer;
            position: absolute;
            top: 0;
            right: 8px;
          }

          .location {
            width: 200px;
            height: 32px;
            margin-top: 27px;
            font-size: 22px;
            color: #23c1fc;
            font-style: italic;
            font-weight: bolder;
            background-image: linear-gradient(#e2f0fe, #2b92b8);
            -webkit-background-clip: text;
            color: transparent;
          }

          .l_item {
            display: flex;
            justify-content: space-between;
            margin-top: 10px;
            font-size: 14px;

            div>span {
              font-size: 20px;
              font-weight: bolder;
              font-style: italic;
              margin-right: 5px;
            }
          }
        }
      }

      .mid_title {
        width: 100%;
        text-align: center;
        font-size: 30px;
        font-weight: bolder;
        height: 50px;
        background: url("@/images/home/titleBG.png") no-repeat;
        background-size: 100% 100%;
      }

      .mid_map {
        flex: 1;
      }

      .mid_pics {
        display: flex;
        background: url("@/images/home/circleBg.png") no-repeat;
        background-size: 100% 100%;
        height: 200px;
        div {
          flex: 1;
          text-align: center;
          // margin-bottom: 50px;
        }

        .pic_div {
          width: 100%;
          font-size: 13px;
          &:nth-of-type(1),
          &:nth-of-type(5) {
            margin-top: -50px;
          }

          &:nth-of-type(2),
          &:nth-of-type(4) {
            margin-top: -30px;
          }
          transition: all .5s;
          transform: translateY(0);
          &:hover {
            transform: translateY(-30px);
          }

          .pics {
            cursor: pointer;
            width: 145px;
            height: 110px;
            margin: 0 auto;
            margin-bottom: 10px;

            img {
              width: 100%;
              height: 100%;
            }
          }

          .tips {
            cursor: pointer;
            width: 100%;
            text-align: center;
          }
        }
      }
    }
  }
}
</style>
